﻿using System.Diagnostics.Contracts;
using OpenLS.Core;

namespace OpenLS.Spreadsheet
{
    internal class SheetRemovedUndoUnit : IUndoUnit
    {
        private readonly Workbook _workbook;
        private readonly Sheet _sheet;
        private readonly int _index;

        public SheetRemovedUndoUnit(Workbook workbook, Sheet sheet, int index)
        {
            Contract.Requires(workbook != null);
            Contract.Requires(sheet != null);
            _workbook = workbook;
            _sheet = sheet;
            _index = index;
        }

        public void Do()
        {
            _workbook.Sheets.Insert(_index, _sheet);
            _workbook.View.ActiveSheet = _sheet;
        }

        public bool Merge(IUndoUnit unit)
        {
            return false;
        }
    }
}